package com.tax.controller;

import com.tax.config.response.Response;
import com.tax.dto.req.CheckValidCodeReq;
import com.tax.dto.res.ValidImgRes;
import com.tax.service.ValidCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * FileName: ValidCodeController
 * Author:   duandehui
 * Date:     2023/3/4 16:06
 * Description: 图形验证码
 */
@RestController
@RequestMapping("/valid/code")
@Api(tags = "图形验证码管理")
public class ValidCodeController {

    @Autowired
    private ValidCodeService validCodeService;
    /**
     * 获取web端的图形验证码
     * @return
     */
    @ApiOperation(value = "获取图形验证码", notes = "获取图形验证码",response = ValidImgRes.class)
    @RequestMapping(value = "/getValidImg",method = RequestMethod.POST)
    public Response<ValidImgRes> getValidImg() {
        ValidImgRes res=validCodeService.getValidImg();
        return new Response<>(res);
    }

    /**
     * 图形验证码校验
     * @return
     */
    @ApiOperation(value = "图形验证码校验", notes = "图形验证码校验")
    @RequestMapping(value = "/checkValidCode",method = RequestMethod.POST)
    public Response<String> checkValidCode(@RequestBody CheckValidCodeReq req) {
        String result=validCodeService.checkValidCode(req);
        return new Response<>(result);
    }
}
